#ifndef DIRECTORIES_AND_FILES_H_
#define DIRECTORIES_AND_FILES_H_


#include<stdio.h>
#include<dirent.h>



#ifdef __cplusplus
extern "C"{
#endif
static char** search_dir_files(char* path,int*count);

#ifdef __cplusplus
}
#endif

static char** search_dir_files(char*path,int * count)
{
    printf("mingw\n");
    
    char** re=NULL;
    DIR* dp=opendir(path);
    struct dirent*dirp=NULL;
    *count=0;
    if(dp==NULL)
    {
        return NULL;
    }
    
    while((dirp=readdir(dp))!=NULL)
    {
        *count=*count+1;
    }
    re=(char**)malloc(sizeof(char*)*(*count));
    closedir(dp);
    dp=opendir(path);
    int i=0;
    while((dirp=readdir(dp))!=NULL)
    {
        re[i]=(char*)malloc(sizeof(char)*(strlen(dirp->d_name)+1));
        strcpy(re[i],dirp->d_name);
        i++;
    }
    closedir(dp); 

    return re;
}




#endif